const Controller = require('egg').Controller

class LoginController extends Controller {
    async index() {
        const { ctx } = this
        await ctx.render('login.html', {
            message: ''
        })
    }

    async getLogin() {
        const { ctx } = this

        let query = ctx.request.body

        const setLoginInfo = await ctx.service.login.find(query)

        if (setLoginInfo == null) {
            await ctx.render('login.html', {
                message: '用户名和密码不存在!'
            })
        } else {
            ctx.session.uid=setLoginInfo
            ctx.redirect('/')
        }
    }
}

module.exports = LoginController